import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { SPetInfo } from "../../../../Message/Game/SPetInfo";
import { Language } from "../../../../extend/language/Language";
import { PetUtil } from "../pet/info/PetUtil";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { PetColor } from "../pet/info/PetColor";
import { PetType } from "../pet/info/PetType";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { PetItem } from "../pet/PetItem";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { GButton } from "../../../../com/mui/controls/GButton";
//class PetHireMyRenderer
    
    export  class PetHireMyRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._petInfo = arg1 as SPetInfo;
            if (this._petInfo) 
            {
                this._petItem.dragSource = this._petInfo;
                this._levelTxt.text = Language.getStringByParam(28023, this._petInfo.reinLevel, this._petInfo.level);
                this._nameTxt.htmlText = PetUtil.getPetName(this._petInfo);
                this._talentTxt.htmlText = HTMLUtil.addColor(this._petInfo.talent.toString(), PetColor.getTalentColor(this._petInfo).color);
                this._typeTxt.htmlText = HTMLUtil.addColor(PetType.getTypeName(this._petInfo.career), PetType.getTypeColor(this._petInfo.career));
                this._growthTxt.htmlText = HTMLUtil.addColor(this._petInfo.growth.toString(), PetUtil.getUpgradeColor(true, this._petInfo.growth));
                this._spiritTxt.htmlText = HTMLUtil.addColor(this._petInfo.spirit.toString(), PetUtil.getUpgradeColor(false, this._petInfo.spirit));
                this._playerTxt.text = this._petInfo.ownerName;
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 15788607);
            var loc2=40;
            var loc3=45;
            ObjCreate.createBg(0, 0, 590, 90, this);
            ObjCreate.createBg(20, 15, 38, 38, this, ImagesConst.PackItemBg);
            this._petItem = new PetItem();
            this._petItem.isDragAble = false;
            this._petItem.isDropAble = false;
            this._petItem.setSize(32, 32);
            this._petItem.move(22, 17);
            this.addChild(this._petItem);
            ObjCreate.createTextField("LV.", 2, 65, 40, 25, this, loc1);
            this._levelTxt = ObjCreate.createTextField("", 24, 65, 40, 25, this, loc1);
            this._levelTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._nameTxt = ObjCreate.createTextField("", 75, 15, 100, 25, this, new GTextFormat(FontUtil.songtiName, 14, 15788607));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createBg(75, loc2, 75, 45, this, ImagesConst.AttrBg);
            ObjCreate.createTextField(Language.getString(54336), 86, loc3, 60, 20, this);
            this._typeTxt = ObjCreate.createTextField("", 75, 65, 75, 20, this, GlobalStyle.textFormat6);
            this._typeTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createBg(155, loc2, 45, 45, this, ImagesConst.AttrBg);
            ObjCreate.createTextField(Language.getString(54208), 163, loc3, 60, 20, this);
            this._talentTxt = ObjCreate.createTextField("", 155, 65, 45, 20, this, GlobalStyle.textFormat6);
            this._talentTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createBg(205, loc2, 45, 45, this, ImagesConst.AttrBg);
            ObjCreate.createTextField(Language.getString(54191), 213, loc3, 60, 20, this);
            this._growthTxt = ObjCreate.createTextField("", 205, 65, 45, 20, this, GlobalStyle.textFormat6);
            this._growthTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createBg(255, loc2, 45, 45, this, ImagesConst.AttrBg);
            ObjCreate.createTextField(Language.getString(54192), 264, loc3, 60, 20, this);
            this._spiritTxt = ObjCreate.createTextField("", 255, 65, 45, 20, this, GlobalStyle.textFormat6);
            this._spiritTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            ObjCreate.createBg(305, loc2, 100, 45, this, ImagesConst.AttrBg);
            ObjCreate.createTextField(Language.getString(54288), 330, loc3, 60, 20, this);
            this._playerTxt = ObjCreate.createTextField("", 305, 65, 100, 20, this, GlobalStyle.textFormat6);
            this._playerTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._detailBtn = ObjCreate.createGButton(Language.getString(54359), 335, 10, 70, 24, this);
            this._detailBtn.drawNow();
            this._detailBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onDetailBtnClickHandler);
            this._fireBtn = ObjCreate.createGButton(Language.getString(54368), 465, 60, 70, 24, this);
            this._fireBtn.drawNow();
            this._fireBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onFireBtnClickHandler);
            return;
        }

        /* internal  */onFireBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._petInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetHireFire, this._petInfo));
            }
            return;
        }

        /* internal  */onDetailBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._petInfo) 
            {
                NetDispatcher.dispatchCmd(ServerCommand.PetHireDetailInfoCommand, this._petInfo);
            }
            return;
        }

        /* internal */ /* var */_petItem: PetItem;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_typeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_talentTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_growthTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_spiritTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_detailBtn: GButton;

        /* internal */ /* var */_fireBtn: GButton;

        /* internal */ /* var */_petInfo: SPetInfo;
    }
